package io.mqttpush.mqttserver.handles;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.mqtt.MqttMessage;
import io.netty.handler.codec.mqtt.MqttMessageType;

import java.util.List;

/**
 * @author tianzhenjiu
 * @date 2020/6/9 17:26
 */
public class DisConnectService implements  Iservice<MqttMessage> {

    @Override
    public boolean accept(ChannelHandlerContext context, MqttMessage inMessage) {

        return MqttMessageType.DISCONNECT==inMessage.fixedHeader().messageType();

    }

    @Override
    public List<Object> service(ChannelHandlerContext context, List<Object> outMessage, MqttMessage inMessage) {

        context.close();

        return outMessage;
    }
}
